<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta charset="UTF-8">
    <title>选择变更表单</title>
</head>
<body>
<div style="max-width: 450px;max-height: 450px;">
    <form id="form" role="form" method="post" th:action="${action}">
        <div class="row">
            <div class="col-md-12">
                <div class="form-group">
                    <label for="stage">选择变更表单</label>
                    <select class="form-control" id="stage" name="stage">
                        <option th:each="model:${changeFroms}"
                                th:value="${model.getId()}"
                                th:text="${model.getChangeNo()}"
                        >
                        </option>
                    </select>
                </div>
                <div id="layout" style="display: none;margin-top: 50px;text-align: center;z-index: 100;" class="layoutLoading">
                    <span style="color: red">发起流程中...</span><br>
                    <img th:src="@{/img/process.gif}"/></div>
            </div>
        </div>
    </form>
</div>
<script th:inline="javascript">
    <![CDATA[
    var butFlag = 0;
    $(function () {
        // 绑定dialog的确定按钮的监听事件
        $("#btnOk", window.top.document).click(function () {
            // var changeFromNo = $("#stage option:selected").text();
            // window.Ewin.confirm({title: '提示', message: '您确定需要对'+changeFromNo+'表单发起流程吗？', width: 500}).on(function (e) {
            //     if(e){
            if(butFlag==0){
                butFlag = 1;
            }else {
                window.Ewin.alert({message: '流程已在发起中，请稍等...'});
                return false;
            }
            var changeFromId = $("#stage option:selected").val();
            $('#layout').show();
            $.ajax({
                type:
                    'POST',
                url: "bomAllCfg/getVwo?projectId="+getProjectUid()+"&changeFromId="+changeFromId,
                success:
                    function (result) {
                        butFlag = 0;
                        activeTabBodyRefresh();
                        if (result.status) {
                            layer.msg(result.msg, {icon: 1, time: 2000})
                        }
                        else {
                            window.Ewin.alert({message: result.msg});
                        }
                    },
                error: function (status) {
                    butFlag = 0;
                    window.Ewin.alert({message: status.status + ':变更失败!'});
                }
            });
            //     }
            // })
        });
    })
    ]]>
</script>
</body>
</html>